package com.jbh.recordlibrary.u;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;

import com.jbh.recordlibrary.f.cheap.CheapWAV;
import com.jbh.recordlibrary.i.CallBack;

import java.io.File;
import java.io.IOException;


public class Utils {


    /**
     * 判断字符串是否为空
     *
     * @param string
     * @return
     */
    public static boolean isEmptyStr(CharSequence string) {
        if (TextUtils.isEmpty(string) || "null".equals(string)) {
            return true;
        } else {
            return false;
        }
    }


    /**
     * @param second
     * @return
     */
    public static String formatSecond(int second){
        String  html = "";
        int s= second/1000; //转化成秒
        int ms=(second%1000)/10;  //转化豪秒
        String format;
        Object[] array;
        Integer hours =(int) (s/(60*60));
        Integer minutes = (int) (s/60-hours*60);
        Integer seconds = (int) (s-minutes*60-hours*60*60);
//        if(hours>0){
//            if(hours>=10){
//                html=hours+"";
//            }else{
//                html="0"+hours;
//            }
//        }else{
//            html="00";
//        }

        if(minutes>0){
            if(minutes>=10){
                html=""+minutes;
            }else{
                html="0"+minutes;
            }
        }else{
            html="00";
        }
        if(seconds>=10){
            html=html+":"+seconds+"."+(ms > 0 ? ms:"00");
        }else{
            html=html+":0"+seconds+"."+(ms > 0 ? ms:"00");
        }
        return html;
    }



    /**
     * @param second
     * @return
     */
    public static String formatSecond1(int second){
        String  time = "";
        int s= second/1000; //转化成秒
        Integer hours =(int) (s/(60*60));
        Integer minutes = (int) (s/60-hours*60);
        Integer seconds = (int) (s-minutes*60-hours*60*60);
//        if(hours>0){
//            if(hours>=10){
//                time=hours+"";
//            }else{
//                time="0"+hours;
//            }
//        }else{
//            time="00";
//        }

        if(minutes>0){
            if(minutes>=10){
                time=""+minutes;
            }else{
                time="0"+minutes;
            }
        }else{
            time="00";
        }

        if(seconds>=10){
            time=time+":"+seconds;
        }else{
            time=time+":0"+seconds;
        }

        return time;
    }













}
